#!/usr/bin/env python
# coding=utf-8

# import requests

# r = requests.get("https://www.baidu.com")

# fo = open("baidu.txt", "w+")

# r.encoding =  'utf-8'
# str = r.text
# line = fo.write( str )

import requests
from bs4 import BeautifulSoup

fo = open("baidu.md","w")

try:
    r = requests.get("https://www.baidu.com")
    r.encoding = r.apparent_encoding
    demo = r.text
    soup = BeautifulSoup(demo,"html.parser")
    fo.write(soup.prettify())
    fo.writelines(soup.prettify())
except:
    print("False")

fo.close()






